




import 'package:data_table_2/data_table_2.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

//flutter 图标学习

void main() {
  // debugProfileBuildsEnabled = true;
  // debugProfilePaintsEnabled = true;
  // debugPaintLayerBordersEnabled = true;
  runApp(GetMaterialApp(home: App()));
}

class App extends StatelessWidget {
  const App({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('table text'),),
      body: Container(
        child: DataTable2SimpleDemo(),
      ),
    );
  }
}




class DataTable2SimpleDemo extends StatelessWidget {
  const DataTable2SimpleDemo();

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.all(16),
      child: DataTable2(
          columnSpacing: 12,
          horizontalMargin: 12,
          minWidth: 600,
          columns: [
            DataColumn2(
              label: Text('Column A'),
              size: ColumnSize.L,
            ),
            DataColumn(
              label: Text('Column B'),
            ),
            DataColumn(
              label: Text('Column C'),
            ),
            DataColumn(
              label: Text('Column D'),
            ),
            DataColumn(
              label: Text('Column NUMBERS'),
              numeric: true,tooltip: '这是提示你的'
            ),
            DataColumn(
                label: Text('详情'),
                numeric: true,tooltip: '这是提示你的'
            ),
          ],
          rows: List<DataRow>.generate(
              5,
                  (index) => DataRow(
                      onSelectChanged:(selected){},
                      cells: [
                DataCell(Text('A' * (10 - index % 10)),
                    onTap: (){
                  if(Get.context != null){
                    Get.defaultDialog(
                        title: "标题",
                        content: Column(
                          children: [
                            Text("第1行"),
                            Text("第2行"),
                            Text("第3行"),
                          ],
                        ),
                        textConfirm: "确认",
                        textCancel: "取消",
                        onConfirm: (){
                          Get.back() ;
                          Get.snackbar(
                            "提醒",
                            "你已经提交成功",
                          );
                        }
                    );
                  }

                    },
    ),
                DataCell(Text('B' * (10 - (index + 5) % 10)),showEditIcon: true,onTap: (){
    print('DataCell onTap');}),
                DataCell(Text('C' * (15 - (index + 5) % 10))),
                DataCell(Text('D' * (15 - (index + 10) % 10))),
                DataCell(Text(((index + 0.1) * 25.4).toString())),
                    DataCell(IconButton(
                      icon: Icon(Icons.add_business),
                      onPressed: ()=>      Get.defaultDialog(
                          title: "标题",
                          content: Column(
                            children: [
                              Text("第1行"),
                              Text("第2行"),
                              Text("第3行"),
                            ],
                          ),
                          textConfirm: "确认",
                          textCancel: "取消",
                          onConfirm: (){
                            Get.back() ;
                            Get.snackbar(
                              "提醒",
                              "你已经提交成功",
                            );
                          }
                      ),
                    ))
              ]))),
    );
  }
}
